package com.jof.framework.hmc.sender;

import java.util.Date;
 
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.core.JmsTemplate;

import com.jof.framework.hmc.domain.HmcMessage;
import com.jof.framework.hmc.domain.SMSMessage;
import com.jof.framework.util.HOPConstant;

public class SendMsgService extends JmsTemplate{
	
	private static final Logger LOG = LoggerFactory.getLogger(SendMsgService.class);
	
	public boolean sendMsg(HmcMessage msg){  
		try{
			if(msg instanceof SMSMessage){
				SMSMessage sms = (SMSMessage)msg;
				sms.setSystem(HOPConstant.getAppName());
				sms.setSendMessageTime(new Date());
			}
			this.convertAndSend(msg);
			return true;
		}catch(Exception e){
			LOG.error("SendMsgService error.",e);
			return false;
		}
	}
}
